package cn.qzuie.smart.module.dorm.dal.mysql.energyusage;

import java.util.*;

import cn.qzuie.smart.framework.common.pojo.PageResult;
import cn.qzuie.smart.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.qzuie.smart.framework.mybatis.core.mapper.BaseMapperX;
import cn.qzuie.smart.module.dorm.dal.dataobject.energyusage.EnergyUsageDO;
import org.apache.ibatis.annotations.Mapper;
import cn.qzuie.smart.module.dorm.controller.admin.energyusage.vo.*;

/**
 * 能源使用 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EnergyUsageMapper extends BaseMapperX<EnergyUsageDO> {

    default PageResult<EnergyUsageDO> selectPage(EnergyUsagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EnergyUsageDO>()
                .eqIfPresent(EnergyUsageDO::getDormitoryId, reqVO.getDormitoryId())
                .eqIfPresent(EnergyUsageDO::getEnergyId, reqVO.getEnergyId())
                .betweenIfPresent(EnergyUsageDO::getPreReadingDate, reqVO.getPreReadingDate())
                .eqIfPresent(EnergyUsageDO::getCurrentReading, reqVO.getCurrentReading())
                .eqIfPresent(EnergyUsageDO::getPreviousReading, reqVO.getPreviousReading())
                .eqIfPresent(EnergyUsageDO::getUserId, reqVO.getUserId())
                .betweenIfPresent(EnergyUsageDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(EnergyUsageDO::getUsage, reqVO.getUsage())
                .orderByDesc(EnergyUsageDO::getId));
    }

}